<template>
	<view>
		<view class="nav-bar">
			<image src="../../../static/back_icon.png" @tap="back" mode=""></image>
			<view class="center">
				添加银行卡
			</view>
			<view class="right">
			</view>
		</view>
		<view class="list">
			<view class="list-call">
				<view class="left">持卡人</view>
				<input class="biaoti" v-model="idName" @input="show" @blur="show" type="text" maxlength="10" placeholder-style="color:#CCCCCC" placeholder="持卡人姓名"/>
			</view>
			<view class="list-call">
				<view class="left">卡号</view>
				<input class="biaoti" v-model="bankNum" @input="show" @blur="show" type="number" placeholder-style="color:#CCCCCC" placeholder="银行卡卡号" />
				<view class=""></view>
			</view>
			<view class="list-call">
				<view class="left">身份证</view>
				<input class="biaoti" v-model="peoidCard" @input="show" @blur="show" type="idcard" placeholder-style="color:#CCCCCC" placeholder="身份证号码" />
			</view>
			<view class="list-call">
				<view class="left">手机号</view>
				<input class="biaoti" v-model="phoneno" @input="show" @blur="show" maxlength="11"  type="number" placeholder-style="color:#CCCCCC" placeholder="银行预留手机号" />
				<view class=""></view>
			</view>
			<view class="list-call">
				<view class="left">验证码</view>
				<input class="biaoti" v-model="code" @input="show" @blur="show" type="number" placeholder-style="color:#CCCCCC" placeholder="验证码" />
				<view class="yzm" :class="{ yzms: second>0 }" @tap="getcode">{{yanzhengma}}</view>
			</view>
		</view>
		<view class="button" :class="showed?'opct':''" @tap="verification">
			验证信息
		</view>
		<!-- 提现提示 -->
		<tui-modal :show="modal"   :custom="true" :maskClosable="false">
			<view class="content">
				<view class="top"> 
					<image src="../../../static/earnings/success_tips.png" mode=""></image>
				</view>
				<view class="middle">绑卡成功，请注意用卡安全</view>
				<view class="bottom" @tap="hide">继续提现</view>
			</view>
		</tui-modal>
	</view>
</template>

<script>
	import tuiModal from "@/components/modal/modal.vue"
	var js;
	export default {
		components: {
			tuiModal
		},
		data() {
			return {
				idName:'',
				bankNum:'',
				peoidCard:'',
				phoneno:'',
				code: '',
				second:0,
				showed:true,
				modal:false
			}
		},
		methods: {
			//导航方法
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			//验证码获取
			getcode() {
				if (this.second > 0) {
					return;
				}
				if (this.phoneno.length != 11) {
					uni.showToast({
						icon: 'none',
						title: '请输入手机号'
					});
					return;
				}
				this.second = 60;
				js = setInterval(()=>{
					this.second--;
					if (this.second == 0) {
						clearInterval(js)
					}
				}, 1000)
			},
			show(event){
				console.log()
				if(this.idName.length > 0&&this.bankNum.length > 0&&this.peoidCard.length > 0&&this.phoneno.length > 0&&this.code.length > 0&&event.target.value.length>0){
					this.showed=false;
				}
				else{
					this.showed=true;
				}
			},
			//验证信息
			verification(){
				if(!this.showed){
					uni.showToast({
						title:":ss"
					});
					this.modal=true;
				}
			},
			hide(){
				this.modal=false;
				uni.navigateTo({
					url:'/pages/earnings/withdrawal/withdrawal'
				})
			},
		},
		computed: {
			yanzhengma() {
				if (this.second == 0) {
					return '获取验证码';
				} else {
					if (this.second < 10) {
						return '重新获取0' + this.second;
					} else {
						return '重新获取' + this.second;
					}
				}
			}
		},
		onUnload() {
			clearInterval(js)
			this.second = 0;
		}
	}
</script>

<style scoped lang="scss">
	.nav-bar {
		height: 128upx;
		padding: 40upx 28upx 0;
		background: #E8271B;
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		width: 750upx;
		z-index: 9;

		image {
			width: 48upx;
			height: 48upx;
		}

		.center {
			font-size: 36upx;
			font-weight: 500;
			line-height: 70upx;
			color: rgba(255, 255, 255, 1);
		}

		.right {
			width: 48upx;
			height: 48upx;
		}
	}
	.list {
		padding-top: 148upx;
		display: flex;
		flex-direction: column;
		padding-left: 58.66upx;
		padding-right: 58.66upx;
	
		.list-call {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: flex-end;
			padding-bottom: 10upx;
			height: 100upx;
			color: #333333;
			border-bottom: 1upx solid rgba(230, 230, 230, 1);
			.left {
				font-size: 28upx;
				width: 130upx;
			}
			.biaoti {
				flex: 1;
				text-align: left;
				font-size: 32upx;
				line-height: 100upx;
				margin-left: 16upx;
			}
		}
	
		.yzm {
			color: #E8271B;
			font-size: 24upx;
			line-height: 64upx;
			padding-left: 10upx;
			padding-right: 10upx;
			width: auto;
			height: 64upx;
			border: 1upx solid #E8271B;
			border-radius: 50upx;
		}
	
		.yzms {
			color: #999999 !important;
			border: 1upx solid #999999;
		}
	}
	.button{
		margin:100upx  auto ;
		width:616upx;
		height:104upx;
		background:rgba(232,39,27,1);
		border-radius:52upx;
		font-size:40upx;
		font-weight:500;
		line-height:104upx;
		color:rgba(255,255,255,1);
		text-align: center;
	}
	.opct{
		opacity:0.5;
	}
	.content{
		.top{
			image{
				width: 72upx;
				height: 72upx;
				display: block;
				margin: 0 auto;
			}
		}
		.middle{
			height: 120upx;
			font-size:34upx;
			font-weight:500;
			line-height:120upx;
			color:rgba(51,51,51,1);
			text-align: center;
		}
		.bottom{
			height: 60upx;
			font-size:34upx;
			font-weight:500;
			color:rgba(51,51,51,1);
			padding-top: 10upx;
			margin: 0 -12%;
			border-top: 1upx solid #F2F2F2;
			text-align: center;
		}
	}
	
</style>
